//
//  headerView.m
//  Dental_Fun
//
//  Created by macbook pro on 15/10/8.
//  Copyright (c) 2015年 YZK. All rights reserved.
//

#import "headerView.h"

@implementation headerView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self= [super initWithFrame:frame]) {
        
        [self addSubview:self.titleLabel];
        
        [self addSubview:self.styelLable];
        
        [self addSubview:self.dingdanHaolBel];
        
        [self addSubview:self.imageButton];
    }

    
    return self;

}


- (void)setYesOrNo:(BOOL)yesOrNo
{

        _titleLabel.frame = CGRectMake(40, CGRectGetMinX(_titleLabel.frame), CGRectGetWidth(_titleLabel.frame), CGRectGetHeight(_titleLabel.frame) - 20);
        _imageButton.hidden = NO;
    


}
- (UILabel *)titleLabel
{
    
    if (_titleLabel) {
        
        return _titleLabel;
    }
    
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, KWidth-100, self.frame.size.height )];
    label.textColor = [UIColor blackColor];
    
    label.font = SET_FONT(16);
    
    _titleLabel = label;
    
    return _titleLabel;
    
}

- (UILabel *)styelLable
{
    if (_styelLable) {
        
        return _styelLable;
    }
    
    UILabel  * label = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.frame)- 110, 5, 100, 20)];
    
//    label.textColor = UIColorRGB(0xcc3333);
    
    label.textAlignment = NSTextAlignmentRight;
    
    label.font = SET_FONT(12);
    
    _styelLable = label;
    
    return _styelLable;
    
    

}

- (UILabel *)dingdanHaolBel
{
    if (_dingdanHaolBel) {
        
        return _dingdanHaolBel;
    }
    
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(self.frame.size.width - 130, self.frame.size.height / 2, 140, 22)];
    
//    label.textColor = UIColorRGB(0x666666);
    label.font = SET_FONT(10);
    
    _dingdanHaolBel = label;
    
    return _dingdanHaolBel;
    
    
    

}

- (UIButton *)imageButton
{
    if (_imageButton) {
        
        return _imageButton;
    }

    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    button.frame = CGRectMake(10, 7, 30, 30);
    
//    [button setImage:SET_IMAGE(@"购物车1") forState:UIControlStateNormal];
    
//    [button setImage:SET_IMAGE(@"diu") forState:UIControlStateSelected];
    
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    button.hidden = YES;
    
    _imageButton = button;
    
    return _imageButton;
}


- (void)buttonClicked:(UIButton *)sender
{
    sender.selected = !sender.selected;
    

}

/*
 
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
